package cn.jbit.utils;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import java.util.ResourceBundle;

/**
 * @author 财龙
 * @Description:
 * @date 2020/10/15 11:26
 */
public class jedisUtil {

    private static JedisPool jedisPool;

    static {
       /* ResourceBundle jedis = ResourceBundle.getBundle("jedis");*/
        //读取资源文件
        ResourceBundle bundle = ResourceBundle.getBundle("jedis" );
        String maxIdle = bundle.getString( "jedis.MaxIdle");
        String maxTotal = bundle.getString("jedis.MaxTotal" );
        String host = bundle.getString("jedis.host" );
        String port = bundle.getString( "jedis.port");

        JedisPoolConfig config = new JedisPoolConfig( );
        config.setMaxTotal(Integer.parseInt(maxTotal));
        config.setMaxIdle(Integer.parseInt(maxIdle));
    jedisPool = new JedisPool(config,host,Integer.parseInt(port));
    }
    public static Jedis getJedis() {
 return  jedisPool.getResource();
    }
}
